package com.ezerg.thrift;

import org.apache.thrift.TProcessor;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TBinaryProtocol.Factory;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TSimpleServer;
import org.apache.thrift.server.TThreadedSelectorServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TTransportException;

public class ThriftServer {
	public static void main(String[] args) {
		try {
			TServer.Args tArgs = new TServer.Args(new TServerSocket(7911));
			Factory proFactory = new TBinaryProtocol.Factory(); 
			TProcessor processor = new ThriftService.Processor<ThriftService.Iface>(
					new ThriftServiceImpl());
			tArgs.processor(processor);
			tArgs.protocolFactory(proFactory);
			//TServer serverThread = new TThreadedSelectorServer(tArgs);
			TServer server = new TSimpleServer(tArgs);
			System.out.println("Start server on port 7911....");
			server.serve();
		} catch (TTransportException e) {
			e.printStackTrace();
		}
	}

}
